<?php
require 'inc_security.php';
$catBase = new Category;
$rss_group_id = array();
$arrCat = $catBase->list_categories(0,'cat_active = 1 AND cat_type="system"','cat_id,cat_name,cat_type','cat_id ASC');
foreach($arrCat as $i=>$cat){
    $tt = '';
    for($j=0;$j<$cat["level"];$j++) $tt .= '|--';
    $rss_group_id[$cat["cat_id"]] = $tt . $cat["cat_name"];
}
     
$list = new dataGrid('rss_id',30);
$list->add('rss_link','Link rss','string',1,0, 'width="120px"');
$list->add('','Emai chủ link','string');
$list->add('rss_group_id','Nhóm','array',1,1);
$list->add('','Active','string');
//$list->add('','Edit','edit');
$list->add('','Delete','delete');
$db_count = new db_count('SELECT count(*) as count 
                            FROM '.$bg_table.'
                            WHERE 1 '.$list->sqlSearch().'
                            ');
$total = $db_count->total;unset($db_count);

$db_listing = new db_query('SELECT * 
                            FROM '.$bg_table.'
                            WHERE 1 '.$list->sqlSearch().'
                            ORDER BY '.$list->sqlSort().' rss_id DESC
                            '.$list->limit($total));
$total_row = mysql_num_rows($db_listing->result);
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="vi" lang="vi" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?=$load_header?>
</head>
<body>
<div class="module_header bold fix"><?=$module_name?></div>
<div id="wrapper">
    <?=$list->showHeader($total_row)?>
    <?php
    $i = 0; 
    ?>
    <?php while($row = mysql_fetch_assoc($db_listing->result)){
        $i++;
    ?>
    <?=$list->start_tr($i,$row[$id_field])?>
    <td>
        <div class="row">
            <div class="span3"><?=form_input('rss_link'.$row[$id_field],$row['rss_link'],'class="span3" onkeyup="check_edit(\'record_'.$i.'\')"')?></div>
        </div>
    </td>
    <td>
        <div class="row">
            <div class="span2">
            <?php
            $db_user = new db_query('SELECT use_id,use_email FROM users WHERE use_id = "'.$row['rss_user_id'].'"');
            $rss_user = mysql_fetch_assoc($db_user->result);
            echo $rss_user['use_email'];
            ?>
            </div>
        </div>
    </td>
    <td>
      Nhóm : <?=form_dropdown('rss_group_id'.$row[$id_field],$rss_group_id,$row['rss_group_id'],'onchange="check_edit(\'record_'.$i.'\')"')?>
    </td>
    <?=$list->showCheckbox('rss_active',$row['rss_active'],$row[$id_field])?>
    <?=$list->showDelete($row[$id_field])?>
    <?=$list->end_tr()?>
    <?}?>
    <?=$list->showFooter()?>
</div>
</body>
</html>